package applications.studentApplicationForm.ui.lib;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComponent;
import javax.swing.JButton;

import org.objectweb.fractal.fraclet.annotations.Interface;
import org.objectweb.fractal.fraclet.annotations.Component;
import org.objectweb.fractal.fraclet.annotations.Attribute;
import org.objectweb.fractal.fraclet.annotations.Requires;

@Component(provides = {@Interface(name = "jButtonItf", signature = org.objectweb.fractal.swing.JButtonItf.class), @Interface(name = "jButtonAttributes", signature = applications.studentApplicationForm.ui.lib.JButtonInterface.class),  @Interface(name = "ontocompointrospection", signature = ontocompo.api.OntoCompoIntrospection.class)})
public class FractalJButton extends JButton implements JButtonInterface, ontocompo.api.OntoCompoIntrospection, ActionListener {
	
	@Attribute()
	protected String semantic_uid;
	
	@Requires(name = "studentformdirectoryservice")
	private applications.studentApplicationForm.fc.api.StudentFormDirectoryService studentformdirectoryservice;

	
	private org.objectweb.fractal.api.Component c;


	@Override
	public org.objectweb.fractal.api.Component getFractalComponent() {
		// TODO Auto-generated method stub
		return c;
	}

	@Override
	public void setFractalComponent(org.objectweb.fractal.api.Component c) {
		this.c = c;
		
	}

	@Override
	public String getUid() {
		// TODO Auto-generated method stub
		return semantic_uid;
	}

	@Override
	public void setUid(String uid) {
		semantic_uid = uid;
		
	}

	@Override
	public JComponent getComponentItSelf() {
		// TODO Auto-generated method stub
		return this;
	}

	@Override
	public void update(Object o) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		setText("");
		addActionListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		if (arg0.getSource() instanceof JButton)
		{
		JButton b = (JButton) arg0.getSource();
		String text = b.getText();
		
		System.out.println("clic sur JButton... "+text);
		
		// test pour verif ?
		studentformdirectoryservice.setYearValue(text);
		}		
	}


}
